#ifndef CONFIG_ADDSTYLE_H
#define CONFIG_ADDSTYLE_H

// #include <QWidget>
#include "config_infoset.h"

namespace Ui
{
    class config_addstyle;
}

class config_addstyle : public QWidget
{
    Q_OBJECT

public:
    explicit config_addstyle(QWidget *parent = nullptr);
    ~config_addstyle();
    bool processJsonCommand(const QString &jsonStr, QString *err); // 解析json命令并处理,返回err
private slots:
    void on_pushButton_add_clicked();

    void on_pushButton_delete_clicked();

    void on_pushButton_save_clicked();
    void on_pb_inport_clicked();

    void on_pb_export_clicked();

    void on_le_tempLimit_textChanged(const QString &arg1);

    void on_le_humLimit_textChanged(const QString &arg1);

    void on_le_projectName_textChanged(const QString &arg1);

    void on_pushButton_change_clicked();

signals:
    void signalToForward(const QString &msg);

private:
    Ui::config_addstyle *ui;
    QTimer serialPortRefreshTimer;
    QString channelId; // 信道选择
    QString uartChannal = "ttyS2";
    QList<QPair<QString, QMap<QString, ConfigInfo>>>
        m_configInfoList; // 有序存储机柜信息
    QString mLevel;
    // QString mTempLimit;
    // QString mHumLimit;
    QString mTittle = "";
    void updateLayout();
    void updateAvailableSerialPorts();
    void parseExternalConfigToMap(const QString &filePath);
};

#endif // CONFIG_ADDSTYLE_H